"""
Case Type   : tools
Case Name   : 执行初始化数据库命令gs_initdb：指定参数--version
Create At   : 2021/01/27
Owner       : opentestcase015
Description :
    1.执行命令：gs_initdb --version
Expect      :
    1.返回gs_initdb版本信息，然后退出
History     :
"""
import unittest
from yat.test import Node
from yat.test import macro
from testcase.utils.Logger import Logger

Logger = Logger()


class Tools(unittest.TestCase):
    def setUp(self):
        Logger.info('----Opengauss_Function_gs_initdb_Case0034 start----')
        self.userNode = Node('PrimaryDbUser')
        self.DB_ENV_PATH = macro.DB_ENV_PATH

    def test_systools(self):
        Logger.info('------执行gs_initdb命令------')
        excute_cmd1 = f'source {self.DB_ENV_PATH};' \
                      f'gs_initdb --version'
        Logger.info(excute_cmd1)
        msg2 = self.userNode.sh(excute_cmd1).result()
        Logger.info(msg2)
        self.assertTrue(msg2.find('gs_initdb (openGauss') > -1)

    def tearDown(self):
        Logger.info('---Opengauss_Function_gs_initdb_Case0034 finish---')
